﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class ValidCode : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!Page.IsPostBack)
        {
            Session["ValidCode"] = Guid.NewGuid().ToString("");
        }
    }
    protected void ButtonValid_Click(object sender, EventArgs e)
    {
        if(Page.IsValid)
        {
            object code = Session["ImageValidator"];
            if(code != null && code.ToString().ToLower() == txtValidCode.Text.Trim().ToLower())
            {
                string url = Request["url"];
                Response.Redirect(url);
                //lblMsg.Text = "OK " + code.ToString();
            }
            else
            {
                //lblMsg.Text = "fail";
                Response.Redirect("http://www.toook.com");
            }
        }
    }
}
